import Area from "./Area.js";
import Tool from "./Tool.js";
import Config from "./Config.js";

export default class Block extends Area {
    constructor(x = 0, y = 0, width = 50, height = 50, imgSrc = Config.ImageAssets.BlockImgs.base) {
        super(x, y, width, height);
        this.imgSrc = imgSrc;
        this.init();
        this.guid = Tool.guid();
    }
    init() {
        this.img = new Image();
        this.img.src = this.imgSrc;
        this.img.onload = function () {

            this.isReady = true;
        }.bind(this);
    }

    render(context) {
        if (this.isReady) {
            context.drawImage(this.img, this.x, this.y, this.width, this.height);
        }
    }
}